﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using M3G;


namespace MyTestProject {

    public class TestPointSpriteMode {
        [Fact]
        public void TestConstructor () {
            var psmode = new PointSpriteMode ();

            var parms = psmode.PointParameters;

            Assert.Equal (1.0f, parms[0]);  // constant
            Assert.Equal (0.0f, parms[1]);  // linear
            Assert.Equal (0.0f, parms[2]);  // quadratic
            Assert.Equal (0.0f, parms[3]);  // min
            Assert.Equal (1.0f, parms[4]);  // max
            Assert.Equal (1.0f, parms[5]);  // threshold
        }

        [Fact]
        public void TestSetPointFadeThreshold () {
            var psmode = new PointSpriteMode ();
            psmode.PointFadeThreshold = 2.0f;

            Assert.Equal (2.0f, psmode.PointParameters[5]);
        }

        [Fact]
        public void TestSetPointSizeAttenuation () {
            var psmode = new PointSpriteMode ();
            psmode.SetPointSizeAttenuation (1.0f, 2.0f, 3.0f);

            Assert.Equal (1.0f, psmode.PointParameters[0]);
            Assert.Equal (2.0f, psmode.PointParameters[1]);
            Assert.Equal (3.0f, psmode.PointParameters[2]);
        }

        [Fact]
        public void TestSetPointSizeClamp () {
            var psmode = new PointSpriteMode ();
            psmode.SetPointSizeClamp (1.0f, 2.0f);

            Assert.Equal (1.0f, psmode.PointParameters[3]);
            Assert.Equal (2.0f, psmode.PointParameters[4]);
        }

        [Fact]
        public void TestDuplicate () {
            var psmode = new PointSpriteMode ();
            psmode.PointFadeThreshold = 2.0f;
            psmode.SetPointSizeAttenuation (1.0f, 2.0f, 3.0f);
            psmode.SetPointSizeClamp (1.0f, 2.0f);
            psmode.UserID = 100;

            var dup = (PointSpriteMode)psmode.Duplicate ();

            var srcParams = psmode.PointParameters;
            var dupParams = dup.PointParameters;

            Assert.Equal (srcParams[0], dupParams[0]);  // constant
            Assert.Equal (srcParams[1], dupParams[1]);  // linear
            Assert.Equal (srcParams[2], dupParams[2]);  // quadratic
            Assert.Equal (srcParams[3], dupParams[3]);  // min
            Assert.Equal (srcParams[4], dupParams[4]);  // max
            Assert.Equal (srcParams[5], dupParams[5]);  // threshold
            Assert.Equal (psmode.UserID, dup.UserID);
        }
    }
}
